<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>06.class的基本运用</title>
</head>
<body>
    
    <script>
        
        // 1.构造函数
        /* function Person(name,age){
            this.name = name;
            this.age = age;
        }
        Person.prototype = {
            constructor: Person,
            print(){
                console.log('我叫'+this.name+'，今年'+this.age+'岁');
            }
        }
        let person = new Person('张三',19)
        console.log(person); */
        

        // 2.通过class面向对象
        class Person {
            constructor(name,age){
                this.name = name;
                this.age = age;
            }
            print(){
                console.log('我叫'+this.name+'，今年'+this.age+'岁');
            }
        }
        let person = new Person('张三',19)
        console.log(person);
        person.print();

    </script>
</body>
</html>